-
Notifications
You must be signed in to change notification settings - Fork 3
인증서버 내 kakao social login을 통한 회원가입 #86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
localhost로 되어있는 부분 경로를 환경변수처리하면 나중에 배포 환경에 적합하게 바꿀 때 편할 것 같아요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오 좋은 부분이에요 감사합니다! 다만 redirectUri를 request에 클라이언트가 보내주시는건데 @Schema를 통해 예시 들어드리는 부분입니당! 저희가 따로 처리하는 부분은 아닌데 어떻게할까요??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 경우에는 게이트웨이에서 passport를 주지 않고 헤더를 직접 확인하는 방식으로 하는걸까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
passport는 토큰을 기반으로 만들어지게 되는데요. 회원가입 부분은 토큰이 없는 상태로 응답해야하는 api 입니당!
mirlee0304
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다! 이번 pr에 대해 상세히 설명해주신 부분 중에서 서비스명만 확인해주세용!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
리프레시 토큰도 전달하는 이유는 뭔가요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
제가 구현한 방식은 최초 회원가입 / 로그인시 응답에 access token과 refresh token을 같이 내려주고 access token을 가지고 요청을 보낼때마다 사용하고 이때 access token이 만료됐다는 에러를 서버가 반환하면 refresh token을 서버로 보내고 새로운 access token을 반환하는 형식을 사용했기 때문입니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
그럼 해당 방식으로 구현 시 리프레시 토큰이 노출될 위험에 대해서는 괜찮은 걸까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
악의있는 탈취자는 통신이 빈번한 Access Token을 탈취할 가능성이 높고 해당부분 방지를 위해 refresh token을 도입했습니다 ! 그리고 말씀해주신 부분에 대한 우려로 rtr기법이 존재하는데 이부분은 리프레시 토큰이 탈취된 상황을 고려하는것은 추후의 일이라고 하셨던 캠프장님 말을 참고해서 추후 고도화 시 도입해보겠습니다 !
Pull request
Related issue
resolve #27
Motivation and context
web 프로덕트이기 때문에 보안을 신경쓰기 위해 client에게 kakao 인가코드를 넘겨받아서 kakao access token을 만들고 해당 token으로 access token과 refresh token을 생성하였습니다.
간결한 코드와 의존성을 낮추기 위해 Feign 클라이언트를 통해 Kakao 인증 API와 통신하여 액세스 토큰을 가져오도록 구현했습니다.
추후 새로운 소셜 로그인이 확장될 것을 대비하여 Request Body에 어떤 Social Type인지 받도록 하였습니다! 받은 Social Type이 Kakao일 경우에 KakaoSocialService로 요청을 보내는 switch - case 문을 사용하였습니다! 또, KakaoSocialService는 SocialService 인터페이스를 구현하고 있습니다. 후에 구글이나 네이버 로그인을 구현하게 될 때 이 인터페이스를 상속받아 구현하도록 설계하였습니다.
카카오 공식문서를 참고하여 구현했습니다. 이해하실 때 flow와 kakao access token을 통해 정보를 얻어올 때 getLoginDto에 담기는 정보와 변수를 확인하실 때 참고하시면 좋을 것 같습니다.
로컬 컴퓨터에 Redis가 설치되어 있지 않을경우 실행되지 않습니다! Redis 설치해주세요!
Solution
How has this been tested
Types of changes
Checklist